﻿using Jugg.Admin.Framework.Controllers;
using Jugg.Admin.Framework.Menu;
using Jugg.Services.Category;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Jugg.Admin.Controllers
{
    [RoutePrefix("category")]
    public class CategoryController : BaseAdminController
    {
        // GET: Category
        private ICategoryService _categoryService;


        public CategoryController(ICategoryService categoryService)
        {
            this._categoryService = categoryService;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [Descriper("功能模块", true, "menu-icon fa fa-caret-right", FatherResource = "Jugg.Admin.Controllers.SystemManageController",Sort = 11)]
        [Route("",Name = "ctegoryIndex")]
        public ActionResult CategoryIndex()
        {
            var list = _categoryService.getAllCache();
            return View(list);
        }

        /// <summary>
        /// 启用或禁用
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("startDisabled",Name = "disabledOrEnabled")]
        public JsonResult DisabledOrEnabled(int id)
        {
            var result = _categoryService.disabledOrNoCategory(id);
            AjaxData.Status = result.Item1;
            AjaxData.Message = result.Item2;
            return Json(AjaxData, JsonRequestBehavior.AllowGet);
        }

    }
}